package com.qf.day12;

import java.util.List;
import java.util.Scanner;

public class TextEditorDemo {

    public static void main(String[] args) {

        TextEditorService textEditorService = new TextEditorServiceImpl();

        while (true) {
            System.out.println("1.插入文本\t 2.查询所有\t 3.删除文本\t 4.修改文本\t 5.在指定行插入文本\t 6.退出");
            Scanner scanner = new Scanner(System.in);
            String i = scanner.nextLine();
            int num = 0;
            String str = "";
            switch (i) {
                case "1":
                    System.out.println("请输入一行文本：");
                    str = scanner.nextLine(); // 读取一行数据
                    System.out.println("debug:"+str);
                    textEditorService.addLine(str);
                    break;
                case "2":
                    List<String> aLl = textEditorService.getALl();
                    aLl.forEach(e-> System.out.println(e));
                    break;
                case "3":
                    num = Integer.valueOf(scanner.nextLine()) ;
                    textEditorService.deleteLine(num);
                    break;
                case "4":
                    num = Integer.valueOf(scanner.nextLine());
                    str = scanner.nextLine();
                    textEditorService.updateLine(num, str);
                    break;
                case "5":
                    num = Integer.valueOf(scanner.nextLine());
                    str = scanner.nextLine();
                    textEditorService.insertLine(num,str);
                    break;
                case "6":
                    System.out.println("886");
                    break;
                default:
                    System.out.println("输入有误");
            }
        }

    }

}
